﻿IF EXISTS (SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'OTCotizacionUpdate')
	BEGIN
		DROP  Procedure  OTCotizacionUpdate
	END
GO

CREATE PROCEDURE [dbo].[OTCotizacionUpdate] 	
	(	
		@Id				AS INT,		
		@FechaEntrega			AS DATETIME	= NULL,	
		@ClienteId				AS VARCHAR(12) = NULL,
		@ArticuloId				AS VARCHAR(13) = NULL ,
		@VendedorId				AS INT = NULL,
		@Referencia				AS VARCHAR(500),	
		@PruebaColor			AS BIT = NULL,
		@Laser					AS BIT = NULL,
		@TrabajoNuevo			AS BIT = NULL,
		@ReimpresionCambios		AS BIT = NULL,
		@ReimpresionExacta		AS BIT = NULL,
		@Cantidad				AS DECIMAL(10,2) = NULL,		
		@TamanoFinal			AS VARCHAR(100) = NULL,		
		@Impresion2Lados		AS BIT = NULL,
		@FullColor				AS BIT = NULL,
		@DosColores				AS BIT = NULL,
		@UnColor				AS BIT = NULL,
		@Pantone				AS BIT = NULL,
		@Otros					AS BIT = NULL,
		@AcabadosFinales		AS VARCHAR(500) = NULL,		
		@Comentarios			AS VARCHAR(500) = NULL,				
		@Factura				AS VARCHAR(100) = NULL,		
		@HorasAcabados			AS DECIMAL(10,2) = NULL,
		@HorasPrensas			AS DECIMAL(10,2) = NULL,
		@GastosIndirectos		AS DECIMAL(10,2) = NULL,
		@CantidadDommies		AS INT = NULL,
		@Observaciones			AS VARCHAR(500) = NULL,
		@Boleta					AS VARCHAR(50) = NULL,
		@VistoBuenoMaquina		AS BIT = NULL,
		@DibujoMontaje			AS VARCHAR(100) = NULL,
		@EstadoId				AS INT = NULL		
		
	)	
AS
BEGIN	
	SET NOCOUNT ON
		
	UPDATE Lit_OT 
	SET	 FechaEntrega = @FechaEntrega, 
		 ClienteId = @ClienteId, 
		 ArticuloId = @ArticuloId, 
		 VendedorId = @VendedorId,
		 Referencia = @Referencia, 
		 PruebaColor = @PruebaColor, 
		 Laser = @Laser, 
		 TrabajoNuevo = @TrabajoNuevo,
		 ReimpresionCambios = @ReimpresionCambios, 
		 ReimpresionExacta = @ReimpresionExacta, 
		 Cantidad = @Cantidad, 
		 TamanoFinal = @TamanoFinal, 
		 Impresion2Lados = @Impresion2Lados, 
		 FullColor = @FullColor, 
		 DosColores = @DosColores,
		 UnColor = @UnColor,
		 Pantone = @Pantone,
		 Otros = @Otros,
		 AcabadosFinales = @AcabadosFinales,
		 Factura = @Factura,
		 HorasAcabados = @HorasAcabados,
		 HorasPrensas = @HorasPrensas,
		 GastosIndirectos = @GastosIndirectos,
		 Comentarios = @Comentarios, 
		 CantidadDommies = @CantidadDommies,
		 Observaciones = @Observaciones,
		 Boleta = @Boleta,
		 VistoBuenoMaquina = @VistoBuenoMaquina,
		 DibujoMontaje = @DibujoMontaje,
		 EstadoId = @EstadoId
	WHERE Id = @Id
			
	SELECT	Id, EmpresaId, NumeroOT, ArticuloId As ProductoId, ClienteId, 
			 FechaEntrega, FechaIngreso, Referencia, VendedorId, 
			 PruebaColor, Laser, TrabajoNuevo,
			 ReimpresionCambios, ReimpresionExacta, Cantidad, TamanoFinal,
			 Impresion2Lados, FullColor, DosColores, UnColor, 
			 Pantone, Otros, AcabadosFinales, Comentarios, Factura,		
			 HorasAcabados, HorasPrensas, GastosIndirectos, 
			 CantidadDommies, Observaciones, Boleta, VistoBuenoMaquina, DibujoMontaje, EstadoId
	FROM Lit_OT
	WHERE Id = @id
		
	SET NOCOUNT OFF
END

GO